package io.renren.modules.tb.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.tb.entity.HouseLogEntity;
import io.renren.modules.tb.service.HouseLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 房源沟通记录
 *
 * @author chengh
 * @email g543391073@gmail.com
 * @date 2019-07-19 16:29:59
 */
@RestController
@RequestMapping("tb/houselog")
public class HouseLogController {
    @Autowired
    private HouseLogService houseLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("tb:houselog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = houseLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("tb:houselog:info")
    public R info(@PathVariable("id") Integer id){
		HouseLogEntity houseLog = houseLogService.getById(id);

        return R.ok().put("houseLog", houseLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("tb:houselog:save")
    public R save(@RequestBody HouseLogEntity houseLog){
		houseLogService.save(houseLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("tb:houselog:update")
    public R update(@RequestBody HouseLogEntity houseLog){
		houseLogService.updateById(houseLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("tb:houselog:delete")
    public R delete(@RequestBody Integer[] ids){
		houseLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
